package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.OrderSetting;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrderSettingMapper extends BaseMapper<OrderSetting> {
    @Select("select orderdate,number,reservations from t_ordersetting where orderdate between #{begin} and #{end}")
    List<OrderSetting> findSettingDate(@Param("begin") String begin,@Param("end") String end);

    @Update("update t_ordersetting set number = #{number} where orderdate = #{s}")
    void updateSettingDate(@Param("s") String s,@Param("number") int number);

    @Select("select count(1) from t_ordersetting where ORDERDATE=#{orderDate} and NUMBER>RESERVATIONS")
    int checkOrderSetting(@Param("orderDate") String orderDate);

    @Update("update t_ordersetting set RESERVATIONS = RESERVATIONS +1 where ORDERDATE=#{orderDate}")
    void updateReservations(@Param("orderDate") String orderDate);
}
